﻿using System;
using UnityEngine;

namespace RenderHeads.Media.AVProVideo.Demos
{
	// Token: 0x02000015 RID: 21
	public class SphereDemo : MonoBehaviour
	{
		// Token: 0x06000067 RID: 103 RVA: 0x00004F90 File Offset: 0x00003190
		private void Start()
		{
			//if (VRDevice.isPresent)
			//{
			//	return;
			//}
			if (SystemInfo.supportsGyroscope)
			{
				Input.gyro.enabled = true;
				base.transform.parent.Rotate(new Vector3(90f, 0f, 0f));
			}
		}

		// Token: 0x06000068 RID: 104 RVA: 0x00004FE4 File Offset: 0x000031E4
		private void OnDestroy()
		{
			if (SystemInfo.supportsGyroscope)
			{
				Input.gyro.enabled = false;
			}
		}

		// Token: 0x06000069 RID: 105 RVA: 0x00004FFC File Offset: 0x000031FC
		private void Update()
		{
			//if (VRDevice.isPresent)
			//{
			//	if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space))
			//	{
			//		InputTracking.Recenter();
			//	}
			//	if (Input.GetKeyDown(KeyCode.V))
			//	{
			//		VRSettings.enabled = !VRSettings.enabled;
			//	}
			//}
			//else
			{
				if (SystemInfo.supportsGyroscope)
				{
					base.transform.localRotation = new Quaternion(Input.gyro.attitude.x, Input.gyro.attitude.y, -Input.gyro.attitude.z, -Input.gyro.attitude.w);
				}
				else if (Input.GetMouseButton(0))
				{
					float num = 40f * -Input.GetAxis("Mouse X") * Time.deltaTime;
					float num2 = 40f * Input.GetAxis("Mouse Y") * Time.deltaTime;
					num = Mathf.Clamp(num, -0.5f, 0.5f);
					num2 = Mathf.Clamp(num2, -0.5f, 0.5f);
					this._spinX += num;
					this._spinY += num2;
				}
				if (!Mathf.Approximately(this._spinX, 0f) || !Mathf.Approximately(this._spinY, 0f))
				{
					base.transform.Rotate(Vector3.up, this._spinX);
					base.transform.Rotate(Vector3.right, this._spinY);
					this._spinX = Mathf.MoveTowards(this._spinX, 0f, 5f * Time.deltaTime);
					this._spinY = Mathf.MoveTowards(this._spinY, 0f, 5f * Time.deltaTime);
				}
			}
		}

		// Token: 0x0400005C RID: 92
		private float _spinX;

		// Token: 0x0400005D RID: 93
		private float _spinY;
	}
}
